# encoding = utf-8
from businessActions.LoginAction import LoginAction
from playwright.sync_api import sync_playwright

url = "xxx"

def testPWLogin():
    try:
        p = sync_playwright().start()
        browser = p.chromium.launch(headless=False)
        # 创建 BrowserContext对象
        context = browser.new_context()
        # 启动跟踪功能
        # context.tracing.start(snapshots=True, sources=True, screenshots=True)
        page = context.new_page()
        page.goto(url)
        loginAction = LoginAction()
        loginAction.pwLogin(page, "xxx", "xxx")
        page.wait_for_timeout(10000)
    except Exception as err:
        raise err
    finally:
        browser.close()
        p.stop()

if __name__ == "__main__":
    testPWLogin()
    print("登录成功")